package com.it.singleDocument;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.junit.Test;

import java.util.List;

public class queryProceccDefinition {

    @Test
    public void test001() {

        //流程中定义的key
        String  processDefinitionKey = "holiday";
        //获取repository
        ProcessEngineConfiguration configuration =
                ProcessEngineConfiguration
                        .createProcessEngineConfigurationFromResource("activiti.cfg.xml");

        ProcessEngine processEngine =
                configuration.buildProcessEngine();

        RepositoryService repositoryService = processEngine.getRepositoryService();
        //查询流程的定义
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        //便利查询
        //遍历查询结果
        List<ProcessDefinition> list = (List<ProcessDefinition>) processDefinitionQuery
                .processDefinitionKey(processDefinitionKey);
    }
}
